<?php
error_reporting(E_ERROR);
$is_auth = false;
try {
    $auth_token = $_COOKIE['id'];
    $auth_data = json_decode(base64_decode(explode('.', $auth_token)[1]));
    $is_auth = $auth_data ? true : false;
    if ($auth_data->exp < time()) {
        $is_auth = false;
    }
} catch (\Throwable $th) {
    //throw $th;
}
?>

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>WeatherAPI</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
</head>

<body>
    <header class="p-3 bg-dark text-white">
        <div class="container">
            <div class="d-flex flex-wrap align-items-center justify-content-center justify-content-lg-start">
                <a href="/" class="d-flex align-items-center mb-2 mb-lg-0 text-white text-decoration-none">
                    <svg class="bi me-2" width="40" height="32" role="img" aria-label="Bootstrap">
                        <use xlink:href="#bootstrap"></use>
                    </svg>
                </a>

                <ul class="nav col-12 col-lg-auto me-lg-auto mb-2 justify-content-center mb-md-0">
                    <li><a href="/" class="nav-link px-2 text-secondary">Home</a></li>
                </ul>
                <?php if($is_auth == true) { ?>
                    <div class="text-end">
                        <a href="/logout.php">
                            <button type="button" class="btn btn-outline-light me-2">Logout</button>
                        </a>
                    </div>
                <?php } else { ?>
                    <div class="text-end">
                        <a href="/login.php">
                        <button type="button" class="btn btn-outline-light me-2">Login</button>
                </a>
                <a href="/register.php">
                        <button type="button" class="btn btn-warning">Register</button>
                </a>
                    </div>
                <?php } ?>
            </div>
        </div>
    </header>
    <div class="container">
        <div class="notifications">
        </div>
